import axios from 'axios'

/**
 * @desc 请求选车数据
 * @returns 接口数据
 */
export function fetchSelectCarList() {
	return axios({
		url: '/api'
	})
}


export interface CarDetailType {
	brand_id: number
	device_id: number
	city_name: string
}

// 请求详情数据
// 请求列表详情接口
export function fetchCarDetail(params: CarDetailType) {
	return axios({
		url: '/detail',
		params
	})
}


export interface PageState {
	pageCode?: number
	pageSize?: number
}


// 请求首页列表数据
export function fetchList(params?: PageState) {
	return axios({
		url: '/api/list',
		method: 'get',
		params
	})
}

export interface postsDetail {
	id: string
}
// 请求首页列表跳转详情接口
export function postsListDetail(data: postsDetail) {
	return axios({
		url: '/api/detail',
		method: 'post',
		data
	})
}
export interface UserLoginState {
	username: string
	password: string
}


// 用户登录
export function postLogin(data: UserLoginState) {
	return axios({
		url: '/api/user/login',
		method: 'post',
		data
	})
}

export interface postMessState {
	'name': string,
	'datetime': string,
	'content': string,
	'url': string
}

export interface addMessState {
	id: string
	data: postMessState
}

export function postAddMess(data: addMessState) {
	return axios({
		url: '/my/message',
		method: 'post',
		data
	})
}

